import java.io.IOException;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.util.Random;


public class TestUI {
    public static void main(String[] args) throws IOException, InterruptedException {
        Socket client = new Socket();
        client.connect(new InetSocketAddress("127.0.0.1",10086));

        OutputStream out = client.getOutputStream();

        long now = System.currentTimeMillis();
        while (System.currentTimeMillis() - now < 1000 * 20){
            Random random = new Random(System.currentTimeMillis());
            ByteBuffer buffer = ByteBuffer.allocate(8 * 19 + 2);
            //2 bytes
            buffer.put((byte) '@');
            buffer.put((byte) '#');

            //8 * 19 bytes
            //press
            buffer.putDouble(1000 * random.nextDouble());
            buffer.putDouble(1000 * random.nextDouble());
            buffer.putDouble(1000 * random.nextDouble());
            buffer.putDouble(1000 * random.nextDouble());
            //temp
            buffer.putDouble(10000 * random.nextDouble());
            buffer.putDouble(10000 * random.nextDouble());
            buffer.putDouble(10000 * random.nextDouble());
            //flowRT
            buffer.putDouble(1000 * random.nextDouble());
            //adc8-9
            buffer.putDouble(1000 * random.nextDouble());
            buffer.putDouble(1000 * random.nextDouble());
            //height
            buffer.putDouble(1000 * random.nextDouble());
            //speed
            buffer.putDouble(2000 * random.nextDouble());
            buffer.putDouble(2000 * random.nextDouble());
            buffer.putDouble(2000 * random.nextDouble());
            buffer.putDouble(2000 * random.nextDouble());
            //torque
            buffer.putDouble(200 * random.nextDouble() - 100);
            buffer.putDouble(200 * random.nextDouble() - 100);
            buffer.putDouble(200 * random.nextDouble() - 100);
            buffer.putDouble(200 * random.nextDouble() - 100);

            buffer.flip();
            out.write(buffer.array());
            out.flush();
            Thread.sleep(10);
        }

        out.close();

    }

}
